package views.features;

import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.KeyListener;

import views.util.GameColors;

@SuppressWarnings("serial")
public class RecoveryPasswordView extends LoginMenuView {
	public RecoveryPasswordView(String currentUser, String secretQuestion) {
		super(currentUser, "");
		main.removeAll();

		secretQuestionLabel.setFont(new Font("Segoe UI", Font.PLAIN, textDim));
		secretQuestionLabel.setForeground(GameColors.ROSSO);
		secretAnswerLabel.setFont(new Font("Segoe UI", Font.PLAIN, textDim));
		secretAnswerLabel.setForeground(GameColors.ROSSO);
		secretQuestionTextField.setFont(new Font("Segoe UI", Font.PLAIN,
				textDim));
		secretAnswerTextField
				.setFont(new Font("Segoe UI", Font.PLAIN, textDim));
		recovery.setPreferredSize(buttonDimesion);
		recovery.setFont(new Font("Segoe UI", Font.PLAIN, 35));
		recovery.setBorderPainted(false);

		gbc = new GridBagConstraints();
		gbc.insets = new Insets(5, 5, 5, 5);

		gbc.gridx = 0;
		gbc.gridy = 0;
		main.add(usernameLabel, gbc);
		gbc.gridx = 1;
		gbc.gridy = 0;
		main.add(userTextField, gbc);

		gbc.gridx = 0;
		gbc.gridy = 1;
		main.add(secretQuestionLabel, gbc);
		gbc.gridx = 1;
		gbc.gridy = 1;
		secretQuestionTextField.setText(secretQuestion);
		main.add(secretQuestionTextField, gbc);

		gbc.gridx = 0;
		gbc.gridy = 2;
		main.add(secretAnswerLabel, gbc);
		gbc.gridx = 1;
		gbc.gridy = 2;
		main.add(secretAnswerTextField, gbc);

		gbc.gridx = 0;
		gbc.gridy = 3;
		gbc.gridwidth = 2;
		gbc.fill = GridBagConstraints.HORIZONTAL;
		main.add(recovery, gbc);

		gbc.gridx = 0;
		gbc.gridy = 4;
		main.add(back, gbc);
	}

	public String getUserTextField() {
		return userTextField.getText();
	}

	public String getsecretAnswerTextField() {
		return secretAnswerTextField.getText();
	}

	public String getsecretQuestionTextField() {
		return secretQuestionTextField.getText();
	}

	public String getPassTextField() {
		return passTextField.getText();
	}

	public void showSecretAnswerError() {
		secretAnswerTextField.setForeground(Color.RED);
	}

	public void removeSecretAnswerError() {
		secretAnswerTextField.setForeground(Color.BLACK);
	}

	public void addKeyListenerToGame(KeyListener kl) {
		secretAnswerTextField.addKeyListener(kl);

	}

	public void setRecoveredPassword(String oldPassword) {
		passTextField.setText(oldPassword);

	}
}
